import { defineStore } from "pinia"
import { newTask } from "@/api"
import { ElMessage } from 'element-plus'
export const useNewTaskStore = defineStore('newTask', {
    state() {
      
    },
    getters: {

    },
    actions: {
        async newTaskHadler(data){
            const formData = new FormData()
            for (const key in data) {
                if(data[key]!=""){
                    formData.append(key, data[key])
                }
            }
            const res=await newTask(formData)
            if(res.data.code == 200) {
                ElMessage.success(res.data.msg)
                window.history.back()
            }else{
                ElMessage.error(res.data.msg)
            }
            // console.log(formData)
            // for (let [key, value] of formData.entries()) {
            //     console.log(key, value);
            // }

        }
    }

})